package org.test.once.manager;

import java.sql.SQLException;
import java.util.List;

import org.test.once.dao.RoleDao;
import org.test.once.model.Role;

public class RoleManager {
	
	/**
	 * 获取用户列表
	 * 
	 * @return
	 */
	public List<Role> searchRoles() {
		List<Role> roles = null;
		try {
			roles = RoleDao.getInstance().searchRoles();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return roles;
	}

	/**
	 * 添加用户
	 * 
	 * @param user
	 */
	public void addRole(Role role) {
		try {
			RoleDao.getInstance().save(role);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 通过Id删除用户
	 * 
	 * @param id
	 */
	public void delRole(int id) {
		try {
			RoleDao.getInstance().deleteRole(id);
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 通过Id查找用户
	 * 
	 * @param id
	 */
	public Role findRoleById(int id) {
		Role role = null;
		try {
			role = RoleDao.getInstance().findRoleById(id);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return role;
	}

	/**
	 * 更新用户
	 * 
	 * @param user
	 */
	public void updateRole(Role role) {
		try {
			RoleDao.getInstance().updateRole(role);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}


}
